<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>客户管理系统</title>
    <link rel="stylesheet" type="text/css" media="screen" href="css/base.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/head.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/addCustomer.css" />
</head>
<body>
<div class="mian-head">
    <div class="mian-head-mid">
        <p class="main-title">客户管理系统</p>
        <div class="mian-head-mid-r">
            <p class="main-hy" th:text="'欢迎：'+${session.myUser.name}+'管理员'"></p>
            <div class="mian-head-mid-r-slpi"></div>
            <p><a th:href="@{getUserMessage(name=${session.myUser.name})}">个人信息</a></p>
            <div class="mian-head-mid-r-slpi"></div>
            <p><a href="logout">退出</a></p>
        </div>
    </div>
</div>
<div class="list-mid">
    <!-- 标题 -->
    <div class="list-title">
        <div class="list-title-div"></div>
        <p>修改个人信息</p>
    </div>

    <!-- 表单 -->
    <form th:action="@{updateUser}" method="post" name="updateUForm"  onsubmit="return checkfun2()">
        <table class="addform-table">
            <tr>
                <td class="addform-1">账户名：</td>
                <td class="addform-2" >
                    <input class="addform-input-text" type="text" name="name" th:value="${user.name}" ><p class="error" style="display: inline-block;color: red;padding-left: 20px" th:text="${nameMsg}"></p>
                    <input   hidden type="text" name="oldname" th:value="${user.name}" >
                </td>
            </tr>
            <tr>
                <td class="addform-1">编号：</td>
                <td class="addform-2" >
                    <input class="addform-input-text" type="text" name="id" th:value="${user.id}" readonly="readonly"/><p class="bukegg">(不可更改)</p>

                </td>
            </tr>
            <tr>
                <td class="addform-1">移动电话：</td>
                <td class="addform-2" >
                    <input class="addform-input-text" type="text" name="phone" th:value="${user.phone}" required="required">

                </td>
            </tr>
            <tr>
                <td class="addform-1">邮箱：</td>
                <td class="addform-2" >
                    <input class="addform-input-text" type="text" name="email" th:value="${user.email}" required="required">
<!--                    <input class="addform-input-text" type="text" hidden name="oldcustomers" th:value="${user.customers}" >-->

                </td>
            </tr>

        </table>
        <div class="usermessagebtndiv">
            <input type="submit" class="toupdateMessagebtn" value="提交" ></input>
            <a class="returnbtm" th:href="@{getUserMessage(name=${session.myUser.name})}">返回</a>
        </div>
    </form>

</div>
<script>
    function checkfun2() {
        var phone=document.forms["updateUForm"]["phone"].value;
        var email=document.forms["updateUForm"]["email"].value;

        var ismobile = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
        console.log(ismobile.test(phone));
        if(phone != "" && !ismobile.test(phone)){
            alert("移动电话号码输入不合法");
            return false;
        }

        var isemail =/^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/;
        console.log(isemail.test(email));
        if(email != "" && !isemail.test(email)){
            alert("邮箱输入不合法");
            return false;
        }
    }
</script>
</body>
</html>